using Newtonsoft.Json;
using System.Net;
using Wechat_PublicNumber.Common;

FastBuilder.FastBuild(args,
(option, configuration) =>
{
    option
    .UseJsonSetting()
    .UseTimeJob()
    .UseCros()
    .UseInjection(s =>
    {
        s.AddNamespaceDI("Repository", DIPattern.Scoped)
         .AddNamespaceDI("Jobs", DIPattern.Scoped);
    })
    .UseIISRestart(s =>
    {
        s.IISRestartTaskIpHost = "http://localhost:5666";
        s.ThisApplicationIpHost = configuration["ApiDomain"];
    })
    .UseGlobalRequestLog(s =>
    {
        s.RequestLogUniqueKey = (token) =>
        {
            return JsonConvert.DeserializeObject<ToeknData>(token).UserID.ToString();
        };
    });

    option.ConfigureServices(service =>
    {
        service.AddHttpClient();
        service.AddHttpClient("GetStock").ConfigurePrimaryHttpMessageHandler(s =>
        {
            return new HttpClientHandler()
            {
                AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
            };
        });
        service.AddMemoryCache();
    });
});